package showtime.framework.net.message
{
	import showtime.framework.algorithm.collections.HashMap;
	
	import flash.utils.ByteArray;
	import flash.utils.Proxy;
	
	public dynamic class BaseMessage extends ByteArray implements IMessage
	{
		
		/**
		 * Input buffer. 
		 */		
		protected var inStream:ByteArray = null;
		
		public var methodCode:uint = METHOD_CODE_NULL;;
		
		public var resultCode:uint = RESULT_CODE_NULL;
		
		public static const METHOD_CODE_NULL:int = 0;
		/**
		 * Create data. 
		 */		
		public static const METHOD_CODE_CREATE:int = 1;
		
		/**
		 * Read data. 
		 */		
		public static const METHOD_CODE_READ:int = 2;
		
		/**
		 * Update data. 
		 */		
		public static const METHOD_CODE_UPDATE:int = 3;
		
		
		/**
		 * Delete data. 
		 */		
		public static const METHOD_CODE_DELETE:int = 4;
		
		/**
		 * List data. 
		 */		
		public static const METHOD_CODE_LIST:int = 5;
			
		/**
		 * Result code. 
		 */		
		public static const RESULT_CODE_NULL:int = 0;
		
		public static const RESULT_CODE_SUCCESS:int = 1;
		
		public static const RESULT_CODE_FAILED:int = 2;

		
		public function BaseMessage(inStream:ByteArray = null)
		{
			if (inStream != null)
			{				
				this.inStream = inStream;
				
				wrap();
			}
			
		}
		
		public function toBuffer():ByteArray
		{
			return this;	
		}
		
		public function wrap():void
		{

		}
		
		/**
		 * Read byte. 
		 * @return 
		 * 
		 */		
		override public function readByte():int
		{
			return inStream.readByte();
		}
		
		override public function readShort():int
		{
			return inStream.readShort();	
		}
		
		override public function readInt():int
		{
			return inStream.readInt();
		}
		
		override public function readDouble():Number
		{
			return inStream.readDouble();
		}
		
		override public function readUTF():String
		{
			return inStream.readUTF();
		}
		
		override public function readObject():*
		{
			return inStream.readObject();
		}
		
	}
}